﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SuperMarketSystem
{
    class MySqlServerUtils
    {
        public static SqlConnection getMySqlServerConnection()//获取一个mysql数据库连接
        {
            String loginConnection = "server=LAPTOP-TC74U8TN;database =sm;uid=sa;pwd=sdjsnm123";
            SqlConnection connectionLogin = new SqlConnection(loginConnection);
            try
            {
                connectionLogin.Open();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.StackTrace);
            }
            return connectionLogin;
        }
        public static void closeSqlServerConnection(SqlConnection connectionLogin)//关闭一个mysql数据库连接
        {
            try
            {
                connectionLogin.Close();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.StackTrace);
            }
        }
    }
}
